package com.rex.mq;

import org.apache.log4j.Logger;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by frt on 2017/11/6.
 *  生产者
 */
@Component
public class Sender {
    private static final Logger logger = Logger.getLogger(Sender.class);

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(){
        String context = "Hello " + new Date();
        logger.info("Sender:" + context);
        this.rabbitTemplate.convertAndSend("hello", context);
    }
}
